home *** CD-ROM | disk | FTP | other *** search
- unit Exwait0;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, AdTerm, AdPort, wincrt;
-
- type
- TForm1 = class(TForm)
- ApdComPort1: TApdComPort;
- ApdTerminal1: TApdTerminal;
- Login: TButton;
- Quit: TButton;
- ApdEmulator1: TApdEmulator;
- procedure LoginClick(Sender: TObject);
- procedure QuitClick(Sender: TObject);
- procedure ApdComPort1WaitChar(CP: TObject; C: Char);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- Index : Byte;
- procedure UpdateTerm(const S : String);
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.UpdateTerm(const S : String);
- begin
- ApdTerminal1.StuffString(^M^J+S+^M^J);
- ApdTerminal1.ForcePaint;
- end;
-
- procedure TForm1.LoginClick(Sender: TObject);
- var
- WaitResult : Integer;
- begin
- {Dial}
- UpdateTerm('dialing...');
- ApdComPort1.Output := 'ATDT260-9726'^M;
-
- {Wait for name prompt or dial error}
- WaitResult := ApdComPort1.WaitForMultiString(
- 'NO CARRIER^NO DIALTONE^BUSY^name?',
- 1092, True, False, '^');
-
- case WaitResult of
- 0, 1, 2, 3 :
- begin
- if WaitResult = 0 then
- UpdateTerm('Timed out during dial attempt')
- else
- UpdateTerm('Failed to connect');
- ApdTerminal1.SetFocus;
- Exit;
- end;
-
- 4 :
- begin
- UpdateTerm('Connected, entering name...');
- ApdComPort1.Output := 'joe blow'^M;
- end;
- end;
-
- {Wait for password}
- if not ApdComPort1.WaitForString('Password?',
- 182, True, False) then begin
- UpdateTerm('Timed out waiting for password prompt');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := '123'^M;
-
- {Wait for menu Nonstop?}
- if not ApdComPort1.WaitForString('Stop?', 182, True, False) then begin
- UpdateTerm('Timed out waiting for prompt');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := ^M;
-
- {Wait for bulletin question}
- if not ApdComPort1.WaitForString('bulletin menu', 182, True, False) then begin
- UpdateTerm('Timed out waiting for prompt');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := 'N';
-
- {Wait for mail question}
- if not ApdComPort1.WaitForString('continue?', 182, True, False) then begin
- UpdateTerm('Timed out waiting for prompt');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := ^M;
-
- {Wait for main menu}
- if not ApdComPort1.WaitForString('Command >>', 182, True, False) then begin
- UpdateTerm('Timed out waiting for prompt');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := 'G';
-
- {Wait for "are you sure" question}
- if not ApdComPort1.WaitForString('Are you sure',
- 182, True, False) then begin
- UpdateTerm('Timed out waiting for are you sure');
- ApdTerminal1.SetFocus;
- Exit;
- end;
- ApdComPort1.Output := 'Y';
-
- {Wait for "NO CARRIER"}
- if not ApdComPort1.WaitForString('NO CARRIER',
- 182, True, False) then begin
- UpdateTerm('Timed out waiting for no connect');
- ApdTerminal1.SetFocus;
- Exit;
- end;
-
- {Say we're finished}
- UpdateTerm('Finished successfully!');
- end;
-
- procedure TForm1.QuitClick(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TForm1.ApdComPort1WaitChar(CP: TObject; C: Char);
- begin
- ApdTerminal1.StuffChar(C);
- ApdTerminal1.ForcePaint;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Index := 0;
- end;
-
- end.
-